package ui.juego.expedientes

import dominio.datos.Hobbie
import dominio.datos.Rasgo
import org.uqbar.arena.bindings.PropertyAdapter
import org.uqbar.arena.layout.ColumnLayout
import org.uqbar.arena.layout.VerticalLayout
import org.uqbar.arena.widgets.Button
import org.uqbar.arena.widgets.Label
import org.uqbar.arena.widgets.List
import org.uqbar.arena.widgets.Panel
import org.uqbar.arena.widgets.TextBox
import org.uqbar.arena.windows.Dialog
import org.uqbar.arena.windows.WindowOwner
import ui.juego.utilidades.IconUtils

class EditarHobbieVillanoDialog extends Dialog<EditarHobbieVillano> {
	
	new(WindowOwner owner, EditarHobbieVillano model) {
		super(owner, model)
		title = "Editar Hobbies"
		iconImage = IconUtils.path
	}
	
	override protected createFormPanel(Panel mainPanel) {
		var Panel contentPanel = new Panel(mainPanel) => [
			layout = new VerticalLayout
		]
		
		new Label(contentPanel).text = "Hobbies:"
		new List<Rasgo>(contentPanel) => [
			bindItemsToProperty("hobbies").adapter = new PropertyAdapter(Hobbie, "dato")
			heigth = 50
			width = 150
			bindValueToProperty("hobbieSeleccionado")
		]
		
		new Button(contentPanel) => [
			
			caption = "Eliminar"
			setAsDefault
			onClick [ |
				modelObject.eliminarHobbieSeleccionado
			]
		]
		
		var Panel addPanel = new Panel(contentPanel) => [
			layout = new ColumnLayout(2)
		]
		new TextBox(addPanel) => [
			bindValueToProperty("inputDato")
		]
		new Button(addPanel) => [
			caption = "Agregar"
			setAsDefault
			onClick [ |
				modelObject.agregarHobbie(new Hobbie(modelObject.inputDato))
			]
		]
		
		new Button(contentPanel) => [
			caption = "Aceptar"
			onClick [ |
				close
			]
		]
	}
	
}